<?php
class Contacts_IndexController extends XPHP_Controller
{
	public function _init()
	{
		$this->loadLayout('/VietTrung_Home');
	}
	
	public function indexAction()
	{
		//Lấy thông tin liên hệ của công ty
		$modelInfor = new Areas_Contacts_Models_Information();
		$modelLang = new Models_Language();
		$arrInfor = $modelInfor->db->where('lang_id', $_SESSION['lang_id'])
									->order_by('position', 'ASC')
									->get()
									->result();
		$this->view->arrInfor = $arrInfor;
		return $this->view();
	}
	
	public function createAJAX()
	{
		$params = $this->params;
		$model = new Areas_Contacts_Models_Contacts();
		$data['create_date'] = XPHP_Date::toTime(date('H:i:s d/m/y'));
		$data['full_name'] = $params['full_name'];
		$data['content'] = $params['content'];
		$data['title'] = $params['title'];
		$data['email'] = $params['email'];
		$data['address'] = $params['address'];
		$data['phone'] = $params['phone'];
		$data['status'] = 0;
		$model->db->insert($data);
		return $this->json(array('success' => true));
	}
}